package org.wbd.pklib.db;

import javax.persistence.*;

/**
 * Klasa realizujaca zwiazek pomiedzy encjami w tabeli item
 * zwiazek miedzy:
 * user
 * repo
 * book
 */
public class ItemJoin implements java.io.Serializable{
	private User user;
	private Repo repo;
	private Book book;
	
	@ManyToOne
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	
	@ManyToOne
	public Repo getRepo() {
		return repo;
	}
	public void setRepo(Repo repo) {
		this.repo = repo;
	}
	
	@ManyToOne
	public Book getBook() {
		return book;
	}
	public void setBook(Book book) {
		this.book = book;
	}
	
	public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
 
        ItemJoin that = (ItemJoin) o;
 
        if (repo != null ? !repo.equals(that.repo) : that.repo != null) return false;
        if (user != null ? !user.equals(that.user) : that.user != null) return false;
        if (book != null ? !user.equals(that.book) : that.book != null) return false;
            
 
        return true;
    }
	
	 
    public int hashCode() {
        int result;
        result = (repo != null ? repo.hashCode() : 0);
        result = 31 * result + (user != null ? user.hashCode() : 0);
        result = 1023 * result + (book != null ? book.hashCode() : 0);
        return result;
    }
	
	
}
